#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
using namespace std;
class Solution {
public:
    bool checkDistances(string s, vector<int>& distance) {
        unordered_map<char,int>map;
        for(int i=0;i<s.size();i++)
        {
            if(map.count(s[i]))
            {
                if(distance[s[i]-'a']!=(i-map[s[i]]-1))return false;
            }
            else {
            map[s[i]]=i;
            }
        }
        return true;
    }
};